1288B - Yet Another Meme Problem - CodeForces Solution


math *1100

Please click on ads to support us..

Python Code:

t = int(input())
for i in range(t):
    a,b = [i for i in input().split()]
    toadd = 0
    cmpr = '9'*len(b)
    if int(b) == int(cmpr):
        toadd = 1
    print(int(a)*(len(b)-1+toadd))

C++ Code:

// Problem: B. Yet Another Meme Problem
// Contest: Codeforces - Educational Codeforces Round 80 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1288/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms

#include<iostream>
#include <bits/stdc++.h>
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
using namespace std;
#define fio 	   	   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int        	   long long
#define rep(karu,mera,gaon)     for(int karu=mera;karu<gaon;karu++)
#define vi 		   	   vector<int>
#define pb         	   push_back
#define mii        	   map<int,int>
#define all(x)         (x).begin(),(x).end()
#define endl           '\n' 
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pii        	   pair<int,int>
#define pno            cout<<"NO"<<endl
#define pys            cout<<"YES"<<endl
#define fi         	   first
#define se         	   second
#define mp             make_pair
#define setbits(x)     __builtin_popcountll(x)
#define ctz(x)         __builtin_ctzll(x)
#define clz(x)         __builtin_clzll(x)
#define uniq(v)        (v).erase(unique(all(v)),(v).end())
#define sz(x)          (int)((x).size())
#define inf        	   3e18//9223372036854775807//2147483647
#define ld             long double
#define ps(x,y)        fixed<<setprecision(y)<<x
                                
const int mod=1e9+7;//998244353;
const int MAX=1e6;
const long double PI=3.14159265359;
const long double eps=1e-6;                  
//-10
void solve()
{
    fio;
    // int n;cin>>n;
    // vi a(n);
    // rep(i,0,n)
    // cin>>a[i];
    // for(int a=1;a<=100;a++)
    // {
    	// for(int b=1;b<=1000;b++)
    	// {
    		// int l = a + b + a*b;
    		// string R = to_string(a)+to_string(b);
    		// int r = stol(R);
    		// if(l==r)
    		// cout<<a<<' '<<b<<endl;
    	// }
    // }
    int A,B;
    cin>>A>>B;
    int b = 9;
    int ans = 0;
    while(b<=B)
    {
    	ans += A;
    	b = 10 * b + 9;
    }
    cout<<ans<<endl;
    return;
}


int32_t main(){
    fio;
    int t=1;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
    	//cout<<"Case #"<<i<<": ";
    	solve();
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

1237A - Balanced Rating Changes
1616A - Integer Diversity
1627B - Not Sitting
1663C - Pōja Verdon
1497A - Meximization
1633B - Minority
688B - Lovely Palindromes
66B - Petya and Countryside
1557B - Moamen and k-subarrays
540A - Combination Lock
1553C - Penalty
1474E - What Is It
1335B - Construct the String
1004B - Sonya and Exhibition
1397A - Juggling Letters
985C - Liebig's Barrels
115A - Party
746B - Decoding
1424G - Years
1663A - Who Tested
1073B - Vasya and Books
195B - After Training
455A - Boredom
1099A - Snowball
1651D - Nearest Excluded Points
599A - Patrick and Shopping
237A - Free Cash
1615B - And It's Non-Zero
1619E - MEX and Increments
34B - Sale